package com.csi.service.impl;

import com.csi.dao.GuestsDao;
import com.csi.dao.impl.GuestsDaoImpl;
import com.csi.domain.Guests;
import com.csi.service.GuestsService;

import java.sql.SQLException;
import java.util.List;

public class GuestsServiceImpl implements GuestsService {
    @Override
    public List<Guests> findAll() {
        GuestsDao guestsDao=new GuestsDaoImpl();
        List<Guests> all = null;
        try {
            all = guestsDao.findAll();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return all;
    }

    @Override
    public int insert(Guests guests) {
        GuestsDao guestsDao=new GuestsDaoImpl();
        int insert = 0;
        try {
            insert = guestsDao.insert(guests);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return insert;
    }

    @Override
    public int update(Guests guests) {
        GuestsDao guestsDao=new GuestsDaoImpl();
        int update = 0;
        try {
            update = guestsDao.update(guests);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return update;
    }

    @Override
    public int delete(int guestsId) {
        GuestsDao guestsDao=new GuestsDaoImpl();
        int delete = 0;
        try {
            delete = guestsDao.delete(guestsId);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return delete;
    }
}
